package com.dps.recommend.beans;

import com.alibaba.fastjson.JSON;
import org.slf4j.MDC;

import java.io.Serializable;

public class DpsDataResult implements Serializable {
    private static final int SUCCESS = 0;
    private static final String SUCCESS_MSG = "success";

    protected Integer return_code;

    protected String return_message;

    protected String requestId;

    protected Object data;

    public static DpsDataResult successWithData(Object data) {
        return new DpsDataResult(SUCCESS, SUCCESS_MSG, data);
    }

    public static DpsDataResult success(int code) {
        return new DpsDataResult(code);
    }

    public static DpsDataResult successWithMsg(String msg) {
        return new DpsDataResult(msg);
    }

    public static DpsDataResult error(int returnCode) {
        return new DpsDataResult(returnCode);
    }

    public static DpsDataResult error(int returnCode, String msg) {
        return new DpsDataResult(returnCode, msg);
    }

    public static DpsDataResult errorWithMsg(int returnCode, String msg) {
        return new DpsDataResult(returnCode, msg, null);
    }

    public DpsDataResult() {
        super();
    }

    public DpsDataResult(int returnCode) {
        this.return_code = returnCode;
        this.return_message = SUCCESS_MSG;
        this.requestId = MDC.get("requestId");
    }

    public DpsDataResult(int returnCode, String msg) {
        this.return_code = returnCode;
        this.return_message = msg;
        this.requestId = MDC.get("requestId");
    }

    public DpsDataResult(Object data) {
        this.return_code = SUCCESS;
        this.return_message = SUCCESS_MSG;
        this.data = data;
        this.requestId = MDC.get("requestId");
    }

    public DpsDataResult(String msg) {
        this.return_code = SUCCESS;
        this.return_message = msg;
        this.requestId = MDC.get("requestId");
    }

    public DpsDataResult(Integer code, Object data) {
        this.return_code = code;
        this.return_message = SUCCESS_MSG;
        this.data = data;
        this.requestId = MDC.get("requestId");
    }

    public DpsDataResult(Integer code, String message, Object data) {
        this.return_code = code;
        this.return_message = message;
        this.data = data;
        this.requestId = MDC.get("requestId");

    }

    public Integer getReturn_code() {
        return return_code;
    }

    public void setReturn_code(Integer return_code) {
        this.return_code = return_code;
    }

    public String getReturn_message() {
        return return_message;
    }

    public void setReturn_message(String return_message) {
        this.return_message = return_message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String toJsonStr() {
        return JSON.toJSONString(this);
    }

    public String getRequestId() {
        return requestId;
    }


}
